// --------------------------------------------------------------------------------------------------------------------
// <copyright company="Roman '4ux-nbIx' Novitsky" file="ControlExtensions.cs">
//   Copyright (c) Roman '4ux-nbIx' Novitsky 2010
// </copyright>
// <summary>
//   Defines the Control class extension methods.
// </summary>
// --------------------------------------------------------------------------------------------------------------------


namespace MtgMC
{
    #region Namespace Imports

    using System;
    using System.Drawing;
    using System.Windows.Forms;

    #endregion


    /// <summary>
    /// Defines Control class extension methods.
    /// </summary>
    public static class ControlExtensions
    {
        #region Public Methods

        /// <summary>
        /// Gets the size of the text.
        /// </summary>
        /// <param name="control">
        /// The control.
        /// </param>
        /// <param name="text">
        /// The text to measure.
        /// </param>
        /// <param name="font">
        /// The text font.
        /// </param>
        /// <param name="widthIncreasePercent">
        /// The width increase percent.
        /// </param>
        /// <returns>
        /// The <see cref="SizeF">Size</see> of the text.
        /// </returns>
        public static SizeF GetTextSize(this Control control, string text, Font font, int widthIncreasePercent)
        {
            SizeF textSize = control.CreateGraphics().MeasureString(text, font);

            textSize.Width += textSize.Width / 100 * widthIncreasePercent;
            textSize.Width = (float)Math.Ceiling(textSize.Width);

            return textSize;
        }

        #endregion
    }
}